<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
 * Default Kohana controller. This controller should NOT be used in production.
 * It is for demonstration purposes only!
 *
 * @package    Core
 * @author     Kohana Team
 * @copyright  (c) 2007-2008 Kohana Team
 * @license    http://kohanaphp.com/license.html
 */
class Index_Controller extends BaseController {
	public function __construct()
	{
		parent::__construct();
	}
	public function index()
	{
		// In Kohana, all views are loaded and treated as objects.
		$this->template->content = new View('index');
		// You can assign anything variable to a view by using standard OOP
		// methods. In my welcome view, the $title variable will be assigned
		// the value I give it here.
		$this->template->title = 'E-study Web Application';

		$this->template->breadcrumbs = '';

		$Templateforums = ORM::factory('forum')->orderby('for_order', 'asc')->find_all();
		$forums = array();
		$forumsTitle = '';
		foreach($Templateforums as $forum)
		{
			if($forum->for_hassub  == 1)
			{
		  $forumsTitle = $forum->for_name;
			}
			if($forum->for_hassub  == 1)
			{
				$forums[$forumsTitle]["Template"][]  = $forum;
			}
			else
			{
				$forums[$forumsTitle]["SubTemplate"][]  = $forum;
			}
		}
		//var_dump($subjects);
		$this->template->content->forums = $forums;
		//$this->template->render(true);
	}
}